<template>
    <div class="container">
        <div class="con">
            <div v-if="list&&list.length==0" class="no-data"><i class="iconfont icon-icon-test1"></i>暂无数据</div>
            <yd-infinitescroll v-if="list.length!=0" :callback="loadList" ref="infinitescrollDemo">
                <yd-preview v-for="(item, key) in list" :buttons="btns" :key="key" slot="list">

                    <yd-preview-header>
                        <div slot="left">MT5账号</div>
                        <div slot="right">{{item.accountId}}</div>
                    </yd-preview-header>
                    <yd-preview-item>
                        <div slot="left">出金MT5交易账号</div>
                        <div slot="right">{{item.mt5Account}}</div>
                    </yd-preview-item>
                    <yd-preview-item>
                        <div slot="left">订单号</div>
                        <div slot="right">{{item.orderId}}</div>
                    </yd-preview-item>
                    <yd-preview-item>
                        <div slot="left">出金USD</div>
                        <div slot="right">{{item.orderAmountUSD}}</div>
                    </yd-preview-item>
                    <yd-preview-item>
                        <div slot="left">申请时间</div>
                        <div slot="right">{{item.createTime}}</div>
                    </yd-preview-item>
                    <yd-preview-item>
                        <div slot="left">出金状态</div>
                        <div slot="right">{{item.status==1?'已出金':(item.status==0?'正在审核':'出金失败')}}</div>
                    </yd-preview-item>
                    <yd-preview-item>
                        <div slot="left">审核时间</div>
                        <div slot="right">{{item.auditTime}}</div>
                    </yd-preview-item>
                    <yd-preview-item>
                        <div slot="left"></div>
                        <div slot="right">
                            <a :href="'./goldoutRecordDetail.html?pId=46&navId=63&id='+item.id"
                               class="yd-btn yd-btn-primary">详情</a>
                        </div>
                    </yd-preview-item>
                </yd-preview>
                <!-- 数据全部加载完毕显示 -->
                <span slot="doneTip">啦啦啦，啦啦啦，没有数据啦~~</span>

                <!-- 加载中提示，不指定，将显示默认加载中图标 -->
                <img slot="loadingTip" src="http://static.ydcss.com/uploads/ydui/loading/loading10.svg"/>
            </yd-infinitescroll>
            <yd-backtop></yd-backtop>
        </div>
    </div>
</template>
<script>
    import AjaxHttp from '../../js/ajaxHttp.js';
    export default{
        data(){
            return {
                page: 1,
                pageSize: 10,
                btns: [],
                list: []
            }
        },
        created(){
            this.getList(false, this.page, this.pageSize);
        },
        methods: {
            loadList(){
                console.log(this.page);
                this.getList(true, this.page, this.pageSize);
            },
            getList(flag, pageNo, pageSize, startDate, endDate, dateType){
                const _this = this;
                startDate = startDate ? startDate + '00:00:00' : '';
                endDate = endDate ? endDate + '23:59:59' : '';
                dateType = dateType ? dateType : 1;
                const url = 'fxsys/inOUTCash/inOutCashRecord?pageNo=' + pageNo + '&pageSize=' + pageSize + '&startDate=' + startDate + '&endDate=' + endDate + '&dateType=' + dateType;
                AjaxHttp.getHttp(url).then(function (response) {
                    console.log(response);
                    if (flag) {
                        const _list = response.records;
                        _this.list = _this.list.concat(_list);
                        console.log(_list.length);
                        if (_list.length < _this.pageSize) {
                            /* 所有数据加载完毕 */
                            _this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.loadedDone');
                            return;
                        }

                        /* 单次请求数据完毕 */
                        _this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.finishLoad');
                    } else {
                        _this.list = response.records;
                    }
                    _this.page++;
                });
            }
        }
    }
</script>